#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<assert.h>
typedef int DataType;
typedef struct BinaryTreeNode
{
	DataType x;
	struct BinaryTreeNode* left;
	struct BinaryTreeNode* right;
}BinaryTreeNode;
BinaryTreeNode* BuyNode(int n)
{
	BinaryTreeNode* newnode = (BinaryTreeNode*)malloc(sizeof(BinaryTreeNode));
	if (newnode == NULL)
	{
		perror("MALLOC FAIL");
		exit(1);
	}
	newnode->x = n;
	newnode->left = newnode->right = NULL;
	return newnode;
}
BinaryTreeNode* CreatNode()
{
	BinaryTreeNode* node1 = BuyNode(1);
	BinaryTreeNode* node2 = BuyNode(2);
	BinaryTreeNode* node3 = BuyNode(3);
	BinaryTreeNode* node4 = BuyNode(4);
	BinaryTreeNode * node5 = BuyNode(5);
	BinaryTreeNode* node6 = BuyNode(6);

	node1->left = node2;
	node1->right = node4;
	node2->left = node3;
	node4->left = node5;
	node4->right = node6;
	return node1;
}
void PrevRoot(BinaryTreeNode* root)
{
	if (root == NULL)
	{
		printf("N");
		return;
	}
	printf("%d", root->x);
	PrevRoot(root->left);
	PrevRoot(root->right);

}
void InRoot(BinaryTreeNode* root)
{
	if (root == NULL)
	{
		printf("N");
		return;
	}
	InRoot(root->left);
	printf("%d", root->x);
	InRoot(root->right);

}
//int size = 0;
//int TreeSize(BinaryTreeNode* root)
//{
//	if (root == NULL)
//	{
//		return 0;
//	}
//	else
//	{
//		size++;
//		TreeSize(root->left);
//		TreeSize(root->right);
//
//	}
//	return size;
//}
int TreeSize(BinaryTreeNode* root,int *size)
{
	if (root == NULL)
	{
		return 0;
	}
	else
	{
		(*size)++;
		TreeSize(root->left,size);
		TreeSize(root->right,size);

	}
	
}
int main()
{
	BinaryTreeNode* root = CreatNode();
	PrevRoot(root);
	printf("\n");
	InRoot(root);
	printf("\n");

	/*printf("%d\n", TreeSize(root));
	size = 0;
	printf("%d\n", TreeSize(root));*/
	int size = 0;
	TreeSize(root, &size);
	printf("%d", size);
	return 0;

}